<template>
  <div class="avatar-frame">
      <div
        class="avatar-frame__avatar"
        :style="{
          background: avatarObj.color,
        }"
      >
        {{avatarObj.name[1]}}
      </div>
      <div class="avatar-frame__collective">
        <div class="avatar-frame__title">
          <span class="avatar-frame__name">{{person.userName}}</span>
          <span class="principal">@负责人</span>
        </div>
        <div class="avatar-frame__tag">
          <span class="tag">决策</span>
          <span class="tag">决策</span>
          <i class="el-icon-more tag-details"></i>
        </div>
      </div>

      <el-dropdown
        placement="right-start"
        class="avatar-frame__details"
      >
        <i class="el-icon-edit"></i>
        <el-dropdown-menu slot="dropdown" :visibleArrow="false">
          <el-dropdown-item>编辑权限</el-dropdown-item>
          <el-dropdown-item>删除</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
  </div>
</template>

<script>
import ddAvatar from './avatar'
export default {
  name: 'avatar-frame',
  props: {
    person: {}
  },
  computed: {
    avatarObj () {
      return ddAvatar.getAvatar(this.person.userName)
    }
  }
}
</script>

<style scoped>
.avatar-frame{
  display:flex;
  width: 210px;
  height:76px;
  box-shadow: 0 0 1px 1px #E5E5E5;
  border-radius: 4px;
  padding: 12px;
  box-sizing: border-box;
  position: relative;
  margin-right: 12px;
}
.avatar-frame:hover{
  box-shadow: 0 0 2px 2px #FF8E3D;
  transition: box-shadow 0.1s ease-in-out;
}
.avatar-frame__avatar{
  width: 52px;
  height: 52px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
}

.avatar-frame__collective{
  display: flex;
  flex-direction: column;
  margin-left: 12px;
  max-width: 120px;
}
.avatar-frame__title{
  display: flex;
}
.avatar-frame__name{
  font-size: 16px;
  color:#222222;
  font-weight: bold;
  text-align: start;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: auto;
}
.avatar-frame__title .principal{
  flex: none;
  line-height: 26px;
  font-size: 10px;
  font-weight: normal;
  color:#FF8E3D;
  margin-left: 4px;
}
.avatar-frame__details{
  position:absolute;
  top: 0;
  right: 8px;
}
.avatar-frame__tag{
  display: flex;
  align-items: flex-end;
}
.avatar-frame__tag .tag{
  display: inline-block;
  box-sizing: border-box;
  width:40px;
  height:22px;
  font-size:12px;
  color:#1677FF;
  background-color: #EDF5FF;
  border: 1px solid #97C3FF;
  border-radius: 4px;
  margin-right: 8px;
}
.tag-details{
  font-size:12px;
  color: #666666;
}
</style>
